import fetch from 'common/src/utils/fetch';
import UTILS from "common/src/utils/utils";
// 获取学生注册列表
export function getStudentRegisterList(data = {}) {
    return fetch({
        url: '/api/studentservice/activationSetting/activationList',
        method: 'get',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    });
}

/**
 * 注册权限管理列表
 * @param {*} data
 */
export function registConfigList(data) {
    return fetch({
        url: '/api/studentservice/stuRegister/registConfigList',
        method: 'post',
        data
    });
}
/**
 * 添加权限管理
 * @param {*} data
 */
export function addRegistConfig(data) {
    return fetch({
        url: '/api/studentservice/stuRegister/addRegistConfig',
        method: 'post',
        data
    });
}
/**
 * 根据id获取注册权限配置信息
 * @param {*} data
 */
export function getRegistConfig(id) {
    return fetch({
        url: '/api/studentservice/stuRegister/getRegistConfig?id=' + id,
        method: 'get'
    });
}
/**
 * 编辑注册权限配置
 * @param {*} data
 */
export function updateRegistConfig(data) {
    return fetch({
        url: '/api/studentservice/stuRegister/updateRegistConfig',
        method: 'post',
        data
    });
}
/**
 * 删除注册权限配置
 * @param {*} data
 */
export function deleteRegistConfig(id) {
    return fetch({
        url: '/api/studentservice/stuRegister/deleteRegistConfig?id=' + id,
        method: 'DELETE'
    });
}

/**
 * 学生注册管理列表
 * @param {*} data
 */
export function registManageList(data) {
    return fetch({
        url: '/api/studentservice/stuRegister/registManageList',
        method: 'post',
        data
    });
}

/**
 * 导出注册情况列表
 */
export function exportRegistList(query) {
    let params = '';
    for (let key in query) {
        if (
            query[key] &&
            key !== 'pageSize_' &&
            key !== 'pageNum_' &&
            query[key].length !== 0
        ) {
            params += key + '=' + query[key] + '&&';
        }
    }
    return '/api/studentservice/stuRegister/exportRegistList?' + params;
}

/**
 * 导出学信网DBF
 */
export function exportStuRegisteredDbf(query) {
    let params = '';
    for (let key in query) {
        if (
            query[key] &&
            key !== 'pageSize_' &&
            key !== 'pageNum_' &&
            query[key].length !== 0
        ) {
            params += key + '=' + query[key] + '&&';
        }
    }
    return '/api/studentservice/stuRegister/exportStuRegisteredDbf?' + params;
}
/**
 * 根据提示信息列出个层级注册区间
 * @param {*} calendarId
 */
export function registPrompt(calendarId) {
    return fetch({
        url: '/api/studentservice/stuRegister/registPrompt?calendarId=' +
            calendarId
    });
}

/**
 * 添加未注册原因
 */
export function addUnregisteredReason(ids, unregisteredReason) {
    return fetch({
        url: '/api/studentservice/stuRegister/addUnregisteredReason?ids=' +
            ids +
            '&unregisteredReason=' +
            unregisteredReason,
        method: 'get'
    });
}
/**
 * 撤销注册
 */
export function deregistration(ids) {
    return fetch({
        url: '/api/studentservice/stuRegister/deregistration?ids=' + ids,
        method: 'get'
    });
}
/**
 * 学生注册或学院教务员批量注册
 */
export function registered(ids) {
    return fetch({
        url: '/api/studentservice/stuRegister/registered?ids=' + ids,
        method: 'get'
    });
}
/**
 * 学籍管理员特殊注册
 * @param {*} data
 */
export function specialRegist(params) {
    let query = '?';
    for (let key in params) {
        query += key + '=' + params[key] + '&';
    }
    return fetch({
        url: '/api/studentservice/stuRegister/specialRegist' + query,
        method: 'get'
    });
}
/**
 * 学籍管理员新生注册
 * @param {*} data
 */
export function newStuRegistered(data) {
    return fetch({
        url: '/api/studentservice/stuRegister/newStuRegistered',
        method: 'post',
        data
    });
}
/**
 * 学籍管理员新生注册
 * @param {*} data
 */
export function newStuRegist(calendarId) {
    return fetch({
        url: '/api/studentservice/stuRegister/newStuRegist?calendarId=' +
            calendarId,
        method: 'get'
    });
}

/**
 * 信息变更管理列表
 * @param {*} data
 */
export function fieldApprovalList(data) {
    return fetch({
        url: '/api/studentservice/fieldApprovalManage/fieldApprovalList',
        method: 'post',
        data
    });
}

/**
 * 学籍管理员新生注册
 * @param {*} data
 */
export function exportApprovalList(params) {
    let query = '?';
    for (let key in params) {
        if (params[key] != null) query += key + '=' + params[key] + '&';
    }
    return '/api/studentservice/fieldApprovalManage/exportApprovalList' + query;
}

/**
 * 单个审批
 * @param {*} data
 */
export function getApproval(id) {
    return fetch({
        url: '/api/studentservice/fieldApprovalManage/approval?id=' + id,
        method: 'get'
    });
}

/**
 * 批量审批通过
 * @param {*} data
 */
export function throughBatch(data) {
    return fetch({
        url: '/api/workflow/approval/through/batch',
        method: 'post',
        data
    });
}

/**
 * 批量审批拒绝
 * @param {*} data
 */
export function rejectBatch(data) {
    return fetch({
        url: '/api/workflow/approval/reject/batch',
        method: 'post',
        data
    });
}

/**
 * 学生注册页面
 * @param {*} data
 */
export function studentregist(data) {
    return fetch({
        url: '/api/studentservice/stuRegister/studentregist',
        method: 'post',
        data
    });
}
/**
 * 获取最大校历
 */
export function getMaxCalendar() {
    return fetch({
        url: '/api/studentservice/stuRegister/getMaxCalendar',
        method: 'get'
    });
}
export function selectApproveHistory(no) {
    return fetch({
        url: '/api/studentservice/fieldApprovalManage/selectApproveHistory?no=' + no,
        method: 'get'
    });
}
/**
 * 获取特殊注册学生信息
 * @param {*} studentId
 * @param {*} calendarId
 */
export function specialRegistStudent(studentId, calendarId) {
    return fetch({
        url: '/api/studentservice/stuRegister/specialRegistStudent?calendarId=' + calendarId + '&studentId=' + studentId,
        method: 'get'
    });
}
/**
 * 获取权限管理中允许注册的学期
 */
export function getAllowCalendar() {
    return fetch({
        url: '/api/studentservice/stuRegister/getAllowCalendar',
        method: 'get'
    });
}
/**
 * 学生注册操作日志
 * @param {*} data
 */
export function registeredLogList(data) {
    return fetch({
        url: '/api/studentservice/stuRegister/registeredLogList',
        method: 'post',
        data
    });
}
/**
 * 导出学生注册操作日志列表
 * @param {*} query
 */
export function exportRegisteredLog(query) {
    let params = '';
    for (let key in query) {
        if (
            query[key] !== null && query[key] !== '' &&
            key !== 'pageSize_' && key !== 'pageNum_' && key !== 'total_'

        ) {
            params += key + '=' + query[key] + '&&';
        }
    }
    return '/api/studentservice/stuRegister/exportRegisteredLog?' + params;
}
/**
 * 学生撤回变更信息
 * @param {*} data
 */
export function retractApproval(data) {
    return fetch({
        url: '/api/studentservice/fieldApprovalManage/retractApproval',
        method: 'post',
        data
    });
}

/**
 * 注册统计 列表接口
 * @param {*} data
 */
export function registdStatistics(data) {
    return fetch({
        url: '/api/studentservice/stuRegister/registdStatistics',
        method: 'post',
        data
    });
}

// 导出注册统计列表
export function exportList(data) {
    return fetch({
        url: `/api/studentservice/stuRegister/exportStatistics`,
        method: 'Post',
        data
    });
}

// 导出2
export function exportExcelS(data) {
    return fetch({
        url: `/api/studentservice/export/result/` + data,
        method: 'get',
        data
    })
}

// 导出3
export function exportExcelT(data, isOverseas) {
    return fetch({
        url: `/api/studentservice/export/file/?path=` + data,
        method: 'get',
        data,
        responseType: 'blob'
    }).then(res => {
        UTILS.downloadFile(res, isOverseas === 0 ? '中国生注册报到统计.xls' : '国际生注册报到统计.xls', 'application/vnd.ms-excel;charset=utf-8');

    });
}

// 导出学籍注册DBF
export function exportStatusDbf(query) {
    let params = '';
    for (let key in query) {
        if (query[key]) {
            params += key + '=' + query[key] + '&&';
        }
    }
    // return fetch({
    //   url: `/api/studentservice/stuRegister/exportStatusDbf?`+params,
    //   method: 'get'

    // });
    return `/api/studentservice/stuRegister/exportStatusDbf?` + params
}

// 导出学籍注册DBF
export function exportStuRegisteredYearDbf(query) {
    let params = '';
    for (let key in query) {
        if (query[key]) {
            params += key + '=' + query[key] + '&&';
        }

    }
    // return fetch({
    //   url: `/api/studentservice/stuRegister/exportStuRegisteredYearDbf?`+params,
    //   method: 'get'

    // });
    return '/api/studentservice/stuRegister/exportStuRegisteredYearDbf?' + params
}

// 导出贫困地区专项生标注DBF/导出预科生资格核对DBF
export function exportMatAndPovertyDbf(query) {
    let params = '';
    for (let key in query) {
        if (query[key]) {
            params += key + '=' + query[key] + '&&';
        }

    }
    return '/api/studentservice/stuRegister/exportMatAndPovertyDbf?' + params
}

// 导出放弃、保留入学资格DBF
export function exportAdmissionDbf(query) {
    let params = '';
    for (let key in query) {
        if (query[key]) {
            params += key + '=' + query[key] + '&&';
        }

    }
    if (query.keep === false) {
        params += 'keep' + '=' + false + '&&';
    }
    return '/api/studentservice/stuRegister/exportAdmissionDbf?' + params
}   